﻿using AutoMapper;
using BasicInformationWrite.API.BasicInformationCommons.suppliers;
using ERPSystem.Common.Domains.supplier;
using ERPSystem.Common.DTO;
using ERPSystem.Enum.CommonErrorCodes;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BasicInformationWrite.API.Controllers
{
    /// <summary>
    /// 采购管理控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SupplierController : ControllerBase
    {
        private readonly IMediator _mediator;

        public SupplierController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 供应商添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>

        [HttpPost]
        public async Task<Result> supplierCreate(supplierCreateCommand request, CancellationToken cancellationToken)
        { 
            var result = await _mediator.Send(request);
            return result;
        }
        /// <summary>
        /// 采购订单添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> PurchaseOrderCreate(PurchaseOrderCreateCommand request, CancellationToken cancellationToken)
        {
            var result = await _mediator.Send(request);
            return result;
        }
        /// <summary>
        ///采购到货单添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> PurchasedGoodsCreate(PurchasedGoodsCreateCommomand request, CancellationToken cancellationToken) 
        {
            var result = await _mediator.Send(request);
            return result;
        }
        /// <summary>
        /// 导入采购到货单
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> ImportHandle(PurchaseOrderDaoCommand request)
        {
            var result = await _mediator.Send(request);
            return result;

        }
        /// <summary>
        /// 采购订单修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> PurchaseOrderUpdateHandle(PurchaseOrderUpdateCommand request, CancellationToken cancellationToken) 
        {
            var result = await _mediator.Send(request);
            return result;
        }
        /// <summary>
        /// <summary>
        /// 
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> PurchasedGoodsUpdateHandle(PurchasedGoodsUpdateCommomand request, CancellationToken cancellationToken)
        {
            var result = await _mediator.Send(request);
            return result;
        }
    }
}
